﻿@{
    Layout = null;
}
@model ElingOA6_Admin_DSJCJ.Model.Item
<!DOCTYPE html>
@Html.Partial("LoadPanelPartial")
<html>
<head>
<title>用品类别</title>
      @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    
    @Html.DevExpress().GetStyleSheets(

                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

)
    @Html.DevExpress().GetScripts(
                    new Script { ExtensionType = ExtensionType.ListBox }
    )
    <script type="text/javascript">

        $(document).ready(function () {
            var hdjsAlert = $("#hdjsAlert").val();           
            if (hdjsAlert != "") {
                alert(hdjsAlert);
                window.location.href = rootPath + "/Admin/OfficeItemManager/OfficeItemManagerList";
            }
            
        });

        function exist() {
            var itemNo = ASPxClientTextBox.Cast("FItemNo").GetText();
            $.ajax({
                type: 'POST',
                url: rootPath + '/Admin/OfficeItemManager/Exists',
                data: { itemNo: itemNo },
                success: function (result) {
                    if (result == "exist") {
                        alert("该类品编号已经存在，请重新输入!");
                        FItemNo.SetValue("");
                    }
                }
            });
            
         }


        function ok() {

            var itemClsNo = FItemClsName.GetValue();
            if (itemClsNo == "00") {
                alert('请选择一种类别!');
                return;
            }

            var FItemNo = ASPxClientTextBox.Cast("FItemNo");
            if (FItemNo.GetText() == "") {
                alert("用品编号不能为空！");
                return;
            }
            var FItemName = ASPxClientTextBox.Cast("FItemName");
            if (FItemName.GetText() == "") {
                alert("用品名称不能为空！");
                return;
            }
            var FUnit = ASPxClientTextBox.Cast("FUnit");
            if (FUnit.GetText() == "") {
                alert("单位不能为空！");
                return;
            }

            var FSafetyStock = ASPxClientTextBox.Cast("FSafetyStock");
            if (FSafetyStock.GetText() == "") {
                alert("库存报警设定不能为空！");
                return;
            }

            form1.submit();
         }

        function cancel() {
            window.location.href = rootPath + "/Admin/OfficeItemManager/OfficeItemManagerList";
        }

    </script>
</head>
<body>
@using (Html.BeginForm("Save", "OfficeItemManager", FormMethod.Post, new { id = "form1" }))
{

      <table width="60%" align="center" class="tableForm">
       <tr>         
            <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            所属类别:
            </td>
            <td width="35%" valign="middle" class="tdClass" colspan="3">
		      @Html.DevExpress().ComboBox(settings =>
               {
                   settings.Name = "FItemClsName";
                   settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                   settings.Enabled = true;
                   settings.Properties.TextField = "Text";
                   settings.Properties.ValueField = "Value";                  
               }).BindList(ViewData["clsNoList"]).Bind(ViewData["itemClsNo"]).GetHtml()
		    </td>        
        </tr>
        <tr>
            <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            用品编号:
            </td>
            <td width="35%" valign="middle" class="tdClass">
              @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FItemNo";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                   settings.Text = Model.FItemNo;
                   settings.Enabled = (bool)ViewData["itemNo"];
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
                   settings.Properties.ClientSideEvents.KeyDown = "function(s, e){ exist(s ,e)}";
               }).GetHtml()
            </td>           
            <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            用品名称:
            </td>
            <td width="35%" valign="middle" class="tdClass">
		     @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FItemName";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                   settings.Text = Model.FItemName;
                   settings.Enabled = true;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
		    </td>        
        </tr>
        <tr>
            <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            规格:
            </td>
            <td width="35%" valign="middle" class="tdClass">
              @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FItemSpec";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                   settings.Text = Model.FItemSpec;
                   settings.Enabled = true;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>     

            <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            单位:
            </td>
            <td width="35%" valign="middle" class="tdClass">
              @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FUnit";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                   settings.Text = Model.FUnit;
                   settings.Enabled = true;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>             
        </tr>
        
         <tr>
            <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            库存报警设定:
            </td>
            <td width="35%" valign="middle" class="tdClass">
              @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FSafetyStock";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                   settings.Text = Model.FSafetyStock.ToString();
                   settings.Enabled = true;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()

              
            </td>     
            <td colspan="2" class="tdClass">
                <span title="当前库存 或 当前库存减去待领用数 小于等于该设定值时，该物品将标记为报警状态！" style="cursor:hand">
                （默认设置为0）&nbsp;<font color="green">参数说明</font></span>
            </td>            
        </tr>  
          <tr>
             <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            是否启用:
            </td>
            <td width="35%" valign="middle" class="tdClass" colspan="3">
              @Html.DevExpress().CheckBox(settings =>
               {
                   settings.Name = "FIsUse";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                   settings.Checked = Model.FIsUse == "Y" ? true : false;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()              
            </td>   
          
          </tr> 
        <tr>
            <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            当前库存平均单价:
            </td>
            <td width="35%" valign="middle" class="tdClass">
              @Html.DevExpress().Label(settings =>
               {
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                   settings.Text = Model.FPrice.ToString();
                   
               }).GetHtml()
            </td>     

            <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            当前库存库存数量:
            </td>
            <td width="35%" valign="middle" class="tdClass">
               @Html.DevExpress().Label(settings =>
                {
                    settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                    settings.Text = Model.FQty.ToString();
                 }).GetHtml()
            </td>             
        </tr>
             <tr>
            <td width="10%" height="25" align="right" valign="middle" class="tdClass">
            当前库存金额:
            </td>
            <td width="35%" valign="middle" class="tdClass">
              @Html.DevExpress().Label(settings =>
               {
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                   settings.Text = Model.FAmount.ToString();
               }).GetHtml()
            </td>     
            
        </tr>      
    </table>
    
    <table width="100%" class="tableForm">
            <tr>
            <td width="40%">&nbsp;</td>
                <td align="center">
                 @Html.DevExpress().Button(settings =>
            {
                settings.Name = "btnOK";
                settings.Text = "确定";
                settings.ControlStyle.CssClass = "button";
                settings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
                settings.ClientSideEvents.Click = "function(){ok()}";
            }).GetHtml()

                @Html.DevExpress().Button(settings =>
           {
               settings.Name = "btnCancel";
               settings.Text = "取消";
               settings.ControlStyle.CssClass = "button";
               settings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
               settings.CausesValidation = false;
               settings.ClientSideEvents.Click = "cancel";
           }).GetHtml()

                </td>
            </tr>
        </table>
    
    @Html.Hidden("hdjsAlert", ViewData["jsAlert"]);
     @Html.Hidden("hdmessage", ViewData["message"])                                             
    @Html.Hidden("hdtype", ViewData["type"])    
    
    @Html.Hidden("hditemClsNo", ViewData["itemClsNo"])                                            
}
     <script type="text/javascript">
         lp.Hide();
    </script>
</body>
</html>
